package com.xbongbong.pro.enums.menu.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.pro.enums.AccessLinkEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2019/1/15 20:14
 * @desrcption SaaS应用枚举类
 * @since v1.0
 */
@Getter
public enum SystemAppMenuEnum {

    /**
     * SaaS应用枚举
     */
    CRM("CRM", XbbRefTypeEnum.CRM.getAlias(), AccessLinkEnum.CRM),

    PRODUCT(XbbRefTypeEnum.PRODUCT.getI18nName(), XbbRefTypeEnum.PRODUCT.getAlias(), AccessLinkEnum.PRODUCT),

    JXC(XbbRefTypeEnum.JXC.getI18nName(), XbbRefTypeEnum.JXC.getAlias(), AccessLinkEnum.JXC),

    FUND_MANAGEMENT(XbbRefTypeEnum.FUND_MANAGEMENT.getI18nName(), XbbRefTypeEnum.FUND_MANAGEMENT.getAlias(), AccessLinkEnum.FUND_MANAGEMENT),

    WORK_ORDER(XbbRefTypeEnum.WORK_ORDER.getI18nName(),XbbRefTypeEnum.WORK_ORDER.getAlias(), AccessLinkEnum.WORK_ORDER),

    CALL_CENTER(XbbRefTypeEnum.CALL_CENTER_XBB.getI18nName(), XbbRefTypeEnum.CALL_CENTER_XBB.getAlias(), AccessLinkEnum.CALL_CENTER),

    CALL_CENTER_DU_YAN(XbbRefTypeEnum.CALL_CENTER_DU_YAN.getI18nName(), XbbRefTypeEnum.CALL_CENTER_DU_YAN.getAlias(), AccessLinkEnum.CALL_CENTER_DU_YAN),

    GROUP_MESSAGE( XbbRefTypeEnum.GROUP_MESSAGE.getI18nName(), XbbRefTypeEnum.GROUP_MESSAGE.getAlias(), AccessLinkEnum.GROUP_MESSAGE),

    SEARCH_CUSTOMER(XbbRefTypeEnum.SEARCH_CUSTOMER.getI18nName(), XbbRefTypeEnum.SEARCH_CUSTOMER.getAlias(), AccessLinkEnum.SEARCH_CUSTOMER),

    EXPENSE_MANAGEMENT(XbbRefTypeEnum.EXPENSE_MANAGEMENT.getI18nName(), XbbRefTypeEnum.EXPENSE_MANAGEMENT.getAlias(), AccessLinkEnum.EXPENSE_MANAGEMENT),

    ESIGN(XbbRefTypeEnum.ESIGN.getName(), XbbRefTypeEnum.ESIGN.getAlias(), AccessLinkEnum.ESIGN),

    /**
     * 市场管理
     */
    MARKET_MANAGEMENT(XbbRefTypeEnum.MARKET_MANAGEMENT.getName(), XbbRefTypeEnum.MARKET_MANAGEMENT.getAlias(), AccessLinkEnum.MARKET_MANAGEMENT),

    BUNDLE(XbbRefTypeEnum.BUNDLE.getI18nName(),XbbRefTypeEnum.BUNDLE.getAlias(), AccessLinkEnum.BUNDLE),

    COOL_APP(XbbRefTypeEnum.COOL_APP.getI18nName(), XbbRefTypeEnum.COOL_APP.getAlias(), AccessLinkEnum.COOL_APP),

    DISTRIBUTOR(XbbRefTypeEnum.DISTRIBUTOR.getName(), XbbRefTypeEnum.DISTRIBUTOR.getAlias(), AccessLinkEnum.DISTRIBUTOR),

    MARKETING_MANAGEMENT(XbbRefTypeEnum.MARKETING_MANAGEMENT.getName(), XbbRefTypeEnum.MARKETING_MANAGEMENT.getAlias(), AccessLinkEnum.MARKETING_MANAGEMENT),

    ORDER_CENTER(XbbRefTypeEnum.ORDER_CENTER.getName(), XbbRefTypeEnum.ORDER_CENTER.getAlias(), AccessLinkEnum.ORDER_CENTER),

    FINE_CLUE(XbbRefTypeEnum.FINE_CLUE.getI18nName(), XbbRefTypeEnum.FINE_CLUE.getAlias(), AccessLinkEnum.FINE_CLUE),

    CONTRACT_COMPARE(XbbRefTypeEnum.CONTRACT_COMPARE.getI18nName(), XbbRefTypeEnum.CONTRACT_COMPARE.getAlias(), AccessLinkEnum.CONTRACT_COMPARE),

    /**
     * 工单中心
     */
    WORK_ORDER_V2_CENTER(XbbRefTypeEnum.WORK_ORDER_V2_CENTER.getI18nName(), XbbRefTypeEnum.WORK_ORDER_V2_CENTER.getAlias(), AccessLinkEnum.WORK_ORDER_V2_CENTER),

    /**
     * 合同模板库
     */
    CONTRACT_TEMPLATE_BASE(XbbRefTypeEnum.CONTRACT_TEMPLATE_BASE.getName(), XbbRefTypeEnum.CONTRACT_TEMPLATE_BASE.getAlias(), AccessLinkEnum.CONTRACT_TEMPLATE_BASE),
    ;

    /**
     * saas应用标示解释
     */
    private String name;
    /**
     * saas应用标示
     */
    private String alias;
    /**
     * 对应的链接
     */
    private AccessLinkEnum accessLinkEnum;

    SystemAppMenuEnum(String name, String alias, AccessLinkEnum accessLinkEnum){
        this.name = name;
        this.alias = alias;
        this.accessLinkEnum = accessLinkEnum;
    }

    public static SystemAppMenuEnum getSystemAppMenuEnum(String alias){
        for(SystemAppMenuEnum systemAppMenuEnum: values()){
            if(systemAppMenuEnum.getAlias().equals(alias)){
                return systemAppMenuEnum;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public static List<String> getAppAliasList() {
        List<String> alias = new ArrayList<>();
        for (SystemAppMenuEnum systemAppMenuEnum : values()) {
            alias.add(systemAppMenuEnum.getAlias());
        }
        return alias;
    }
}
